#include "rviz_custom_plugins/utils/net_util.h"
#include <QCoreApplication>
#include <QNetworkInterface>
#include <QHostAddress>
#include <QAbstractSocket>


namespace rviz_custom_plugins
{

namespace utils
{

QString getLocalIPv4()
{
    QList<QHostAddress> list = QNetworkInterface::allAddresses();
    for (const QHostAddress &address : list) {
        if (address.protocol() == QAbstractSocket::IPv4Protocol &&
            address != QHostAddress(QHostAddress::LocalHost)) {
            return address.toString();
        }
    }
    return "127.0.0.1"; // fallback
}


}

}